﻿CREATE TABLE [dbo].[ServiceSubscription] (
	[SubscriptionId] uniqueidentifier NOT NULL DEFAULT newid(),
    [CustomerId]   INT              NOT NULL,
    [ServiceId]    UNIQUEIDENTIFIER NOT NULL,
	[VendorId]	   SQL_VARIANT NOT NULL,
    [PaymentCycle] VARCHAR(50)               NOT NULL,
    [IsActive]   BIT               CONSTRAINT [DF_ServiceSubscription_IsActive] DEFAULT ((1)) NOT NULL,
    [DateCreated]  DATETIME         DEFAULT (getdate()) NOT NULL,
    [CreatedBy]    VARCHAR (50)     DEFAULT (suser_sname()) NOT NULL,
    [DateModified] DATE             NULL,
    [ModifiedBy]   VARCHAR (50)     NULL,
    CONSTRAINT [FK_ServiceSubscription_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([CustomerId]) ON DELETE CASCADE ON UPDATE CASCADE,
    CONSTRAINT [FK_ServiceSubscription_SupplierService] FOREIGN KEY ([ServiceId]) REFERENCES [dbo].[SupplierService] ([ServiceId]), 
    CONSTRAINT [PK_ServiceSubscription] PRIMARY KEY ([SubscriptionId])
);


GO

CREATE INDEX [IX_ServiceSubscription_CustomerId] ON [dbo].[ServiceSubscription] ([CustomerId])

GO

CREATE INDEX [IX_ServiceSubscription_ServiceId] ON [dbo].[ServiceSubscription] ([ServiceId])
